#include <QDebug>
#include <QMessageBox>
#include <QTimer>
#include "usbdevice.h"

Usbdevice::Usbdevice(QObject *parent) :
    QObject(parent)
{

}

bool Usbdevice::popUpWarningMsg(QString msg)
{
    QMessageBox::StandardButton rst;
    rst = QMessageBox::warning(NULL, tr("Warning"), msg,
                               QMessageBox::Yes | QMessageBox::No,
                               QMessageBox::No);
    if (rst == QMessageBox::No) {
        return false;
    }
    else {
        return true;
    }
}

void Usbdevice::onMakeClonezillaDevice(int index, QString disk, QString label)
{

    qDebug() << "Thread:" << w.isRunning() << ";"<< w.isFinished();

    if (w.isRunning())
    {
        if (w.wait())
        {
            w.index = index;
            w.disk = disk;
            w.label = label;
            w.start();
            w.timer->start(4000);
        }
    }
    else if(!w.isRunning())
    {
        w.index = index;
        w.disk = disk;
        w.label = label;
        w.start();
        w.timer->start(4000);
    }



}
